﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <title>登录</title>
    <link href="@Html.GetCssSiteUrl()/css/login.css?v=1.0" rel="stylesheet" />
</head>

<body>
    <div class="login">
        <h1>登录</h1>
        <form method="post" action="~/Login" autocomplete="off" id="frmLogin" data-validator-option="{timely:2, theme:'yellow_right_effect'}">
            <input type="text" id="username" name="username" placeholder="账号（随便填）" required="required" data-rule="账号:required;" />
            <input type="password" placeholder="密码（随便填）" required="required" id="password" name="password" data-rule="密码:required;" />
            <button type="submit" class="btn btn-primary btn-block btn-large" id="btnLogin">立即登录</button>
        </form>
    </div>

    <script src="@Html.GetJsSiteUrl()/js/jquery.min.js" type="text/javascript"></script>
    <script src="@Html.GetJsSiteUrl()/lib/nice-validator/jquery.validator.js?local=zh-CN"></script>
    <script src="@Html.GetJsSiteUrl()/lib/layer/layer.js"></script>
    <script type="text/javascript">

        $(document).ready(function (e) {
            $('#frmLogin').validator({
                valid: function (form) {
                    $("#btnLogin").attr("disabled", true);
                    $("#btnLogin").html("登录中。。。");
                    var index = layer.load(1, { shade: [0.1, '#fff'] });
                    $.post($(this).attr("action"), $(form).serialize())
                        .done(function (d) {
                            layer.close(index);
                            layer.closeAll('loading');
                            $("#btnLogin").removeAttr("disabled");
                            $("#btnLogin").html("立即登录");
                            if (d.status == "200") { 
                                location.href = "@ViewData["ReturnUrl"]";
                            } else {
                                alert(d.message);
                            }

                        });
                }
            });

        });
    </script>
</body>

</html>